package com.mayikt.edu.controller;

import com.mayikt.edu.domain.UserLoginLog;
import com.mayikt.edu.service.UserLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 登录日志表(UserLoginLog)表控制层
 *
 * @author wangjin
 * @since 2023-11-02 10:49:04
 */
@Api(value = "登录日志表", tags = "登录日志表")
@RestController
@RequestMapping("userLoginLog")
public class UserLoginLogController {
    /**
     * 服务对象
     */
    @Resource
    private UserLoginLogService userLoginLogService;

    /**
     * 分页查询
     *
     * @param userLoginLog 筛选条件
     * @return 查询结果
     */

    @ApiOperation("分页查询")
    @GetMapping
    public ResponseEntity queryByPage(UserLoginLog userLoginLog) {
        //startPage();
        List<UserLoginLog> list = this.userLoginLogService.queryByPage(userLoginLog);
        return ResponseEntity.ok(list);
    }


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("通过主键查询单条数据")
    @GetMapping("{id}")
    public ResponseEntity queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.userLoginLogService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param userLoginLog 实体
     * @return 新增结果
     */

    @ApiOperation("新增数据")
    @PostMapping
    public ResponseEntity<UserLoginLog> add(@RequestBody UserLoginLog userLoginLog) {
        return ResponseEntity.ok(this.userLoginLogService.insert(userLoginLog));
    }

    /**
     * 编辑数据
     *
     * @param userLoginLog 实体
     * @return 编辑结果
     */

    @ApiOperation("编辑数据")
    @PutMapping
    public ResponseEntity<UserLoginLog> edit(@RequestBody UserLoginLog userLoginLog) {
        return ResponseEntity.ok(this.userLoginLogService.update(userLoginLog));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */

    @ApiOperation("删除数据")
    @DeleteMapping("/{id}")
    public ResponseEntity<Boolean> deleteById(@PathVariable Long id) {
        return ResponseEntity.ok(this.userLoginLogService.deleteById(id));
    }

}

